package com.yql.controller;

import com.yql.entity.User;
import com.yql.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;

@Controller
public class UserController {
    @Autowired
    UserService userService;
    @RequestMapping("login")
    public String login(Integer wkno, String upwd,HttpSession session){
        System.out.println(wkno);
        System.out.println(upwd);
        User user = userService.login(wkno, upwd);
        if (null!=user){
            session.setAttribute("user",user);
            return "redirect:index?url=list";
        }
        return "login";
    }
}
